home *** CD-ROM | disk | FTP | other *** search
- unit Pcxbitmp;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, DelphPCX;
-
- type
- TPCXBitmap = class(TComponent)
- private
- { Private declarations }
- FOnLoadPCX : TNotifyEvent;
- FOnCreate : TNotifyEvent;
- FOnDestroy : TNotifyEvent;
- ThePCXFO : TPCXFileObject;
- protected
- { Protected declarations }
- public
- { Public declarations }
- Width : Longint; { Holds the pixel width when done }
- Height : Longint; { Holds the pixel height when done }
- The_Name : String; { Holds the file name }
- TheBMP : TBitmap;
- constructor Create( AOwner : TComponent ); override;
- destructor Destroy; override;
- procedure Load_PCX_File;
- published
- { Published declarations }
- property FileName : String read The_Name write The_Name;
- property OnCreate : TNotifyEvent read FOnCreate write FOnCreate;
- property OnDestroy : TNotifyEvent read FOnDestroy write FOnDestroy;
- property OnLoadPCXFile : TNotifyEvent read FOnLoadPCX write FOnLoadPCX;
- end;
-
- procedure Register;
-
- implementation
-
-
- { This creates a file bitmap object }
- constructor TPCXBitmap.Create( AOwner : TComponent );
- begin
- { call inherited FIRST! }
- inherited Create( AOwner );
- The_Name := '';
- TheBMP := TBitmap.Create;
- ThePCXFO := TPCXFileObject.Create;
- if Assigned(FOnCreate) then OnCreate( Self );
- end;
-
- { This is the destructor procedure }
- destructor TPCXBitmap.Destroy;
- begin
- if Assigned(FOnDestroy) then OnDestroy(Self);
- ThePCXFO.Free;
- TheBMP.Free;
- { call inherited last }
- inherited destroy;
- end;
-
- procedure TPCXBitmap.Load_PCX_File;
- var
- Test_Win30_Bitmap : Longint;
- Memory_DC : HDC;
- The_IO_Result : Word;
- ThePChar : PChar;
- Bitmap_Handle : hBitmap;
- Bitmap_Palette : hPalette;
- begin
- if Assigned(FOnLoadPCX) then OnLoadPCXFile( Self );
- if The_Name = '' then exit;
- GetMem( ThePChar , 256 );
- StrPCopy( ThePChar , The_Name );
- ThePCXFO.Init( ThePChar );
- FreeMem( ThePChar , 256 );
- ThePCXFO.LoadPCXBitmap( Bitmap_Handle , Bitmap_Palette );
- TheBMP.Handle := Bitmap_Handle;
- TheBMP.Palette := Bitmap_Palette;
- end;
-
- procedure Register;
- begin
- RegisterComponents('Gadgets', [TPCXBitmap]);
- end;
-
- end.
-